home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18055 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.7 KB

  1. Path: dinews.epfl.ch!usenet
  2. From: Bernhard Ruch <Bernhard.Ruch@studi.epfl.ch>
  3. Newsgroups: comp.lang.c++
  4. Subject: Linker error: (Class method name) "multipy defined"
  5. Date: Thu, 18 Apr 1996 19:32:28 +0200
  6. Organization: Ecole Polytechnique Federale de Lausanne
  7. Message-ID: <31767CAC.167E@studi.epfl.ch>
  8. NNTP-Posting-Host: didec11.epfl.ch
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 3.0b2 (X11; I; OSF1 V3.2 alpha)
  13. CC: Bernhard.Ruch@studi.epfl.ch
  14.  
  15. When I try to compile my program, I get the following linker error:
  16.  
  17.   g++ -g -Wall -o ListTest ListTest.o DoubList.o POB_ObjectStream.o
  18.   collect2: ld returned 1 exit status
  19.   /usr/bin/ld:
  20.   DoubList.o: operator>>(POB_ObjectInStream &, DoubleLink *&): multiply defined
  21.   DoubList.o: operator>>(POB_ObjectInStream &, DoubleLinkedList *&): multiply defined
  22.   Warning: Linking some objects which contain exception information sections
  23.           and some which do not. This may cause fatal runtime exception handling
  24.           problems (last obj encountered without exceptions was /usr/local/lib/libstdc++.a).
  25.   Warning: clog defined as GLOBAL DATA but is defined in a shared lib as a GLOBAL FUNC
  26.   *** Exit 1
  27.   Stop.
  28.  
  29.  
  30. I tried to find the problem for a long time, but I could not find it. I looked for 
  31. the definition of the operator >>, but I found only one definition for each of the
  32. two classes (DoubleLink, DoubleLinkedList).
  33.  
  34. There is one thing where I'm not sure if it's correct what I do:
  35.  
  36. I have four classes: POB_Object, POB_ObjectInStream, DoubleLink and DoubleLinkedList
  37.  
  38. The two classes DoubleLink and DoubleLinkedList are derived from POB_Object.
  39.  
  40.  
  41. In the class POB_ObjectInStream, I overload the operator >> several times:
  42.  
  43.     POB_ObjectInStream& POB_ObjectInStream :: operator >> (POB_Object &pObject);
  44.     POB_ObjectInStream& POB_ObjectInStream :: operator >> (POB_Object **ppObject);
  45.  
  46.  
  47. Then, I define two Pointer-types:
  48.  
  49.     typedef DoubleLink* DoubleLinkPointer
  50.     typedef DoubleLinkedList* DoubleLinkedListPointer
  51.  
  52. and overload the operator >> again twice:
  53.  
  54.     POB_ObjectInStream& operator >> (POB_ObjectInStream &pInputStream,  DoubleLinkPointer &pDoubleLink)
  55.     POB_ObjectInStream& operator >> (POB_ObjectInStream &pInputStream,  DoubleLinkListPointer &pDoubleLinkList)
  56.  
  57.  
  58. Now, could it be that the linker doesn't like the two versions of operator>> for 
  59. DoubleLinkPointer& (which is actually also a pointer to POB_Object, since DoubleLink
  60. is derived from POB_Object) and for POB_Object** ?
  61.  
  62. But I suppose that, should this be the case, the compiler should already return an 
  63. error message.
  64.  
  65.  
  66. Does anybody know exactly, what the linker error "multiply defined" means, or where I could get
  67. some documentation about it?
  68.  
  69.  
  70. Thanks
  71.  
  72. Bernhard
  73.